using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using HermesPortal.Core;  
public partial class SagaDefault: PageBase 
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (User.IsInRole("sysAdmin") || this.IsInSagaRole(this.Creator.Id,this.SagaID,SagaRoles.StoryGuide))
        { btnChangeView.Visible = true; }

        SagaView1.SagaID = SagaID;
        SagaEdit1.SagaID = SagaID;
        
    }

    protected void OnClick_ChangeView(object source, EventArgs e)
    {
        SetSagaEditView( SagaView1.Visible); 
    }

    protected void On_ClickSave(object source, EventArgs e)
    {
       SagaEdit1.SaveSagaChanges();
       SetSagaEditView(false); 
    }

    protected void On_ClickCancel(object source, EventArgs e)
    {
        SetSagaEditView(false); 
    }

    private void SetSagaEditView(bool isEditMode)
    {
        if (isEditMode)
            btnChangeView.Text = "Change to Browser View";
        else
            btnChangeView.Text = "Change to Edit View";
        SagaEdit1.Visible = isEditMode;
        SagaView1.Visible = !isEditMode;
        btnUpdate.Visible = isEditMode;
        btnCancel.Visible = isEditMode;
    }

}
